package com.kanqiubao.kq.fragment.live;

import android.graphics.PorterDuff;
import android.view.View;
import android.widget.ImageView;

import androidx.core.content.ContextCompat;

import com.kanqiubao.kq.R;
import com.kanqiubao.kq.fragment.BaseFragment;
import com.kanqiubao.kq.utils.StringUtil;
import com.kanqiubao.kq.view.dialog.CommentPopupView;
import com.kanqiubao.kq.view.dialog.LiveGiftPopupView;
import com.kanqiubao.kq.view.dialog.LivePbBfenPopupView;
import com.lxj.xpopup.XPopup;

public class LiveDetailFragmOne extends BaseFragment<String> implements View.OnClickListener {
    private ImageView mSee;

    @Override
    protected int getLayoutId() {
        return R.layout.live_detail_fragment1_layout;
    }

    @Override
    protected void initView() {
        mSee = findView(R.id.lw_type);
        findView(R.id.go_comment_id).setOnClickListener(this);
        findView(R.id.lw_click_id).setOnClickListener(this);
        findView(R.id.lw_type).setOnClickListener(this);
    }

    @Override
    protected void initData() {

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.go_comment_id:
                buttomComment();
                break;
            case R.id.lw_click_id:
                giftPopupView();
                break;
            case R.id.lw_type:
                pbBfenPopupView(view);
                mSee.setColorFilter(ContextCompat.getColor(getContext(), R.color.main_app_color), PorterDuff.Mode.SRC_IN);
                break;
        }
    }


    private void buttomComment() {
        new XPopup.Builder(getContext())
                .autoOpenSoftInput(true)
                .asCustom(new CommentPopupView(getContext())/*.enableDrag(false)*/)
                .show();
    }

    private void giftPopupView() {
        new XPopup.Builder(getContext())
                .autoOpenSoftInput(false)
                .hasShadowBg(false)
                .asCustom(new LiveGiftPopupView(getContext())/*.enableDrag(false)*/)
                .show();
    }

    LivePbBfenPopupView mLivePbBfenPopupView;

    private void pbBfenPopupView(View v) {
        if (mLivePbBfenPopupView == null) {
            mLivePbBfenPopupView = new LivePbBfenPopupView(getContext()).setmSelelctIml(new LivePbBfenPopupView.selelctIml() {
                @Override
                public void call(String s) {
                    if (StringUtil.isEmptyString(s)) {
                        //沒選中
                        mSee.setImageResource(R.mipmap.icon_show_score_gray);
                    } else {
                        mSee.setImageResource(R.mipmap.icon_hide_score_gray);//屏蔽了
                    }
                }

                @Override
                public void dissmiss(String s) {
                    mSee.clearColorFilter();
                }
            });
        }
        new XPopup.Builder(getContext())
                .hasShadowBg(false)
                .atView(v)
                .asCustom(mLivePbBfenPopupView)
                .show();
    }
}
